How to sort array of object with a condition

welcome to shbcf.ru